<?php
/*
 * Created on 13/02/2009
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 class FixtureRoundDao {
 	var $select = "select fk_season, round, name from fixture_round_names";
 	
 	function FixtureRoundDao() {
 	}
 	
 	function findFixtureRounds($season) {
 	    $rounds = array();
        $rs = executeQuery($this->select . " where fk_season=$season->id");
        while ($row = mysql_fetch_row($rs)) {
        	$fixtureRound = new FixtureRound();
        	$fixtureRound->init($row[0],$row[1],$row[2]);
        	$rounds[$fixtureRound->round] = $fixtureRound;
        }
        return $rounds;
 	}
 	
 	function save($fixtureRounds) {
 		global $season;
 		executeQuery("delete from fixture_round_names where fk_season=$season->id");
 		foreach($fixtureRounds as $fixtureRound) {
 			$name = addslashes($fixtureRound->name);
 			if (strlen($name) == 0) {
 			    $name = '';
 			}
 		    executeQuery("insert into fixture_round_names (fk_season, round, name) values ($season->id, $fixtureRound->round, '$name')");
 		}
 	}
     
 }
?>
